define(function(require, exports){
	var $ = require('jquery');
	var util = require('util');
	var pubjs = require('pubjs');
	var view = require('@base/view');
	var highGrid  = require('@base/highGrid');
	var grid = require('@base/grid');

	var Advertiser = highGrid.base.extend({
		init: function(config){
			config = pubjs.conf(config, {
					url: 'qualification/list',
					reqType: 'websocket',
					cols: [
						{name: '_id', text: LANG('ID'), sort: true, width: 50, align: 'center'},
						{name:'UserName', text:LANG('广告主名称'), type:'index', width: 300, render:"renderName"}
					],
					subs: ["grid_campaign"],
					default_metrics: pubjs.config('metricsGroup/campaign/metrics'),
					tab: pubjs.config('metricsGroup/campaign/tabs'),
					param: {
						// order: '_id|-1',
						order: 'CreateTime|-1'
					},
					subFilter: 'subFilter',
					hasSelect: true,
					hasTab: true,
					hasSwitch: false,
					hasAmount: true,
					hasSearch: false,
					hasExport: true,
					hasRefresh: true,
					hasMenu: true,
					hasTrTitle: true,
					hasBatch: true,
					hasAutoRefresh: true,
					renderTrTitle: this.renderTrTitle
				}
			);

			this.Super('init', arguments);
		},
		renderTrTitle: function(data, tr){
			if(data._id && data.UserName){
				return data._id + '：' + data.UserName;
			}else{
				return '';
			}
		},
		renderName: function(i, val, row, con){
			var html = $('<a class="text-truncate"/>').attr({
				'title': val,
				// 'target': '_blank',
				'href': '#serving/advertiser?aderId='+row._id
			}).text(val);
			return html;
		},
		//subFilter未写
		subFilter: function(subs, data){

		}
	});
	exports.base = Advertiser;

	var selectAdver = grid.base.extend({
		init: function(config){
			config = pubjs.conf(config, {
					url: 'qualification/list',
					reqType: 'websocket',
					cols: [
						{name: '_id', text: LANG('ID'), sort: true, width: 50, align: 'center'},
						{name:'UserName', text:LANG('广告主名称'), type:'index', width: 300}
					],
					subs: ["grid_campaign"],
					default_metrics: pubjs.config('metricsGroup/campaign/metrics'),
					tab: pubjs.config('metricsGroup/campaign/tabs'),
					param: {
						order: 'impressions|-1',
					},
					subFilter: 'subFilter',
					hasSelect: true,
					hasTab: true,
					hasSwitch: false,
					hasAmount: true,
					hasSearch: false,
					hasExport: true,
					hasRefresh: true,
					hasMenu: true,
					hasTrTitle: true,
					hasBatch: true,
					hasAutoRefresh: true,
					renderTrTitle: this.renderTrTitle ,
					pager:{
						size:10
					},
					hasFilter:false
				}
			);

			this.Super('init', arguments);
		}
	});
	exports.selectAdver = selectAdver;
});